#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_not_grabbing_clicked()
{
    ui->label->setText("恭喜抢到红包！");
}

void Widget::on_pushButton_rob_pressed()
{
    //获取窗口的宽度和高度
    int windowwidgth = this->geometry().width();
    int windowheight = this->geometry().height();

    //重新生成位置
    int x = rand() % windowwidgth;
    int y = rand() % windowheight;

    //移动按钮
    ui->pushButton_rob->move(x, y);
}

void Widget::on_pushButton_rob_clicked()
{
    //获取窗口的宽度和高度
    int windowwidgth = this->geometry().width();
    int windowheight = this->geometry().height();

    //重新生成位置
    int x = rand() % windowwidgth;
    int y = rand() % windowheight;

    //移动按钮
    ui->pushButton_rob->move(x, y);
}




